import type { PageList, ResponseStruct } from '#/global'
import { UserVo } from '@/modules/base/api/user';

export interface HomeworkVo {
  id?: number;
  title?: string;
  type?: string;
  remark?: string;
  mode?: string;
  option?: string;
  created_at?: string;
  updated_at?: string;
  creator_id?: number;
  creator?: UserVo
}

export interface HomeworkSearchVo {
  title?: string;
  type?: string;
  mode?: string;
  page_size?:number;
}

export function page(data: HomeworkSearchVo): Promise<ResponseStruct<PageList<HomeworkVo>>> {
  return useHttp().get('/admin/homework', { params: data })
}

export function create(data: HomeworkVo): Promise<ResponseStruct<null>> {
  return useHttp().post('/admin/homework', data)
}

export function save(id: number, data: HomeworkVo): Promise<ResponseStruct<null>> {
  return useHttp().put(`/admin/homework/${id}`, data)
}

export function deleteByIds(ids: number[]): Promise<ResponseStruct<null>> {
  return useHttp().delete('/admin/homework', { data: ids })
}
